package com.java.designpattern.pattern13_iterator;

import java.util.List;

//具体迭代器
class ConcreteIterator implements Iterator
{ 
    private List<Object> list=null;
    private int index=-1; 
    public ConcreteIterator(List<Object> list)
    { 
        this.list=list; 
    } 
    public boolean hasNext()
    {
        return index < list.size() - 1;
    }
    public Object first()
    {
        index=0;
        Object obj=list.get(index);;
        return obj;
    }
    public Object next()
    { 
        Object obj=null; 
        if(this.hasNext())
        { 
            obj=list.get(++index); 
        } 
        return obj; 
    }   
}